
/*
 * Copyright (C) 2008-2009 Archie L. Cobbs. All rights reserved.
 *
 * $Id: SchemaMismatchException.java 204 2009-11-16 19:59:59Z archie.cobbs $
 */

package org.dellroad.sidekar.schema;

import org.dellroad.sidekar.schema.model.SchemaModel;
import org.dellroad.sidekar.util.SidekarException;

/**
 * Exception indicating an attempt was made to open a database
 * that has a different schema from what was expected.
 */
@SuppressWarnings("serial")
public class SchemaMismatchException extends SidekarException {

    private SchemaModel expected;
    private SchemaModel actual;

    public SchemaMismatchException(String message) {
        this(message, null);
    }

    public SchemaMismatchException(String message, Throwable t) {
        this(null, null, message, t);
    }

    public SchemaMismatchException(SchemaModel expected, String message) {
        this(expected, null, message);
    }

    public SchemaMismatchException(SchemaModel expected, SchemaModel actual, String message) {
        this(expected, actual, message, null);
    }

    public SchemaMismatchException(SchemaModel expected, SchemaModel actual, String message, Throwable t) {
        super(message, t);
        this.expected = expected;
        this.actual = actual;
    }

    /**
     * Get the expected schema.
     *
     * @return the schema we expected to see
     */
    public SchemaModel getExpectedSchema() {
        return this.expected;
    }
    public void setExpectedSchema(SchemaModel expected) {
        this.expected = expected;
    }

    /**
     * Get the actual schema.
     *
     * @return the actual schema we sawy (if known, otherwise {@code null})
     */
    public SchemaModel getActualSchema() {
        return this.actual;
    }
    public void setActualSchema(SchemaModel actual) {
        this.actual = actual;
    }
}


